package yxy.game.pm2.future.module;

import org.joda.time.DateTimeConstants;

import yxy.apple.util.redisson.RedisConnection;
import yxy.cherry.game.base.bean.GatewayBean;
import yxy.cherry.game.base.redis.RedisManager;
import yxy.cherry.game.base.redis.RedisType;
import yxy.game.pm2.bean.timeline.FutureRunnable;

public class GatewayBeanFuture extends FutureRunnable {

	@Override
	public void tick() {
		handle();
	}

	@Override
	public long period() {
		return DateTimeConstants.MILLIS_PER_MINUTE * 10;// 10分钟一刷
	}

	@Override
	public void init() {
		handle();
	}

	private void handle() {
		try {
			GatewayBean.refreshBeanMap(redis());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	static protected RedisConnection redis() {
		return RedisManager.getInstance().getConnection(RedisType.REDIS_USER);
	}
}
